package mule.view;

//<editor-fold defaultstate="collapsed" desc="Imports">
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.SceneBuilder;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBuilder;
import javafx.scene.layout.BorderPaneBuilder;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBoxBuilder;
import javafx.scene.layout.RegionBuilder;
import javafx.scene.layout.StackPaneBuilder;
//</editor-fold>

/**
 *
 * @author stephen
 */
public class NewOrLoadView extends View
{
    Button newGameButton;
    Button loadGameButton;
    Scene newOrLoadScreen;

    public Scene getScreen() {
        return createNewOrLoadScreen();
    }

    private Scene createNewOrLoadScreen()
    {
        newOrLoadScreen = SceneBuilder.create()
            .width( SCREEN_WIDTH )
            .height( SCREEN_HEIGHT )
            .root(
                StackPaneBuilder.create()
                .children(
                    RegionBuilder.create()
                    .style( "-fx-background-image: url('mule/view/images/MULE_start_bg2.png');" )
                    .build(),
                    BorderPaneBuilder.create()
                    .center( newOrLoadGameButtons() )
                    .build()
                )
                .build()
            )
        .build();

        return newOrLoadScreen;
    }

    private Node newOrLoadGameButtons()
    {
        newGameButton = ButtonBuilder.create()
            .text( "New Game" )
        .build();

        loadGameButton = ButtonBuilder.create()
            .text( "Load Game" )
        .build();

        HBox buttonBox = HBoxBuilder.create()
            .alignment(Pos.CENTER)
            .spacing(20)
            .children(
                newGameButton,
                loadGameButton
            )
        .build();

        return buttonBox;
    }

    public void addNewGameListener( EventHandler event ) {
        newGameButton.onActionProperty().set( event );
    }

    public void addLoadGameListener( EventHandler event ) {
        loadGameButton.onActionProperty().set( event );
    }
}
